package com.situ.water_Invoice.mapper;

import com.situ.water_Invoice.pojo.IvIninvoice;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.situ.water_Invoice.pojo.IvInvoice;
import com.situ.water_Invoice.pojo.JPTYPE;
import javafx.scene.control.Pagination;
import org.apache.ibatis.annotations.*;
import org.springframework.stereotype.Repository;

import java.util.List;
import java.util.Map;

/**
 * <p>
 *  Mapper 接口
 * </p>
 *
 * @author Angel
 * @since 2020-12-01
 */
@Mapper
public interface IvIninvoiceMapper extends BaseMapper<IvIninvoice> {

    //查询StartNo 比较数据库和输入框的StartNo (发票开始号码)
    @Select("SELECT * FROM IV_Ininvoice WHERE StartNo=#{value}")
    public IvIninvoice queryId(String StartNo);

    //发票入库
    @Insert("INSERT INTO iv_ininvoice(InvoiceType,StartNo,EndNo,InCounts,InEmpID) VALUES(#{InvoiceType},#{StartNo},#{EndNo},#{InCounts},#{InEmpID})")
    public int addivininvoice(IvIninvoice ivIninvoice);

    //查询刚刚入库的id
    @Select("SELECT * from iv_ininvoice ORDER BY ID DESC LIMIT 1")
    public IvIninvoice Ivinid();

    //发票出库 - 发票类型
    @Select("select * from IV_InInvoice where IV_InInvoice.StartNo=#{StartNo} and IV_InInvoice.EndNo=#{EndNo}")
    public IvIninvoice type(String StartNo,String EndNo);

    //发票交票 - 发票类型
    @Select("select iv.InvoiceType,iv.ID,ivo.InID,e.EmpNmae from IV_InInvoice iv,iv_outinvoice ivo,sy_emp e where iv.id=ivo.InID and e.ID=ivo.InID and ivo.StartNo=#{StartNo} and ivo.EndNo=#{EndNo}")
    public JPTYPE jptype(@Param("StartNo") String StartNo,@Param("EndNo") String EndNo);

}
